#include <iostream>
#include <algorithm>
#include <cstdio>
#include <array>
#include <cstring>
using namespace std;
#ifdef OLINE_JUDGE

#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 23], *p1 = buf, *p2 = buf, ubuf[1 << 23], *u = ubuf;

#endif
int read() {
	int p = 0, flg = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') flg = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		p = p * 10 + c - '0';
		c = getchar();
	}
	return p * flg;
}
void write(int x) {
	if (x < 0) {
		x = -x;
		putchar('-');
	}
	if (x > 9) {
		write(x / 10);
	}
	putchar(x % 10 + '0');
}
const int N = 1e6 + 5, mod = 998244353;
array <int, N> s;
int f[N][11][2];
void Mod(int &x) {
	if (x >= mod) x -= mod;
}
int dfs(int step, int now, bool tp, int n, int k) {
	if (step >= n && !now) return 0;
	if (step >= n) return f[step][now][tp] = 1;
	if (f[step][now][tp]) return f[step][now][tp];
	for (int i = now; i <= (tp ? s[step + 1] : k - 1); i++) {
		f[step][now][tp] += dfs(step + 1, i, (tp && i == s[step + 1]), n, k);
		Mod(f[step + 1][i][(tp && i == s[step + 1])]);
	}
	return f[step][now][tp];
}
void Sub1(int n, int k) {
	dfs(0, 0, 1, n, k);
	write(f[0][0][1]), puts("");
}
void Sub2(int n, int k) {

}
void solve(int n, int k) {

}
int main() {
	freopen("count.in", "r", stdin);
	freopen("count.out", "w", stdout);
	int n = read(), k = read();
	for (int i = 1; i <= n; i++)
		s[i] = read();
	Sub1(n, k);
	return 0;
}
